<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>LIST STUDENT</title>
</head>
<link rel="stylesheet" type="text/css" href="/easyui/1.3.4/themes/default/easyui.css" />
<link rel="stylesheet" type="text/css" href="/css/wu.css" />
<link rel="stylesheet" type="text/css" href="/css/icon.css" />
<script type="text/javascript" src="/js/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="/easyui/1.3.4/jquery.easyui.min.js"></script>
<script type="text/javascript" src="/easyui/1.3.4/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="/js/jquery-form.js"></script>
<body>
	<c:if test="${activeUser.tid != -1 }">
		<table class="easyui-datagrid" style="width:700px;height:250px" id="dg_dishes_info5"
			data-options="fitColumns:true,border:false,fit:true,rownumbers:true,singleSelect:true,url:'<%=request.getContextPath()%>/addController/listStudent',method:'get',toolbar:toolbar,pagination:true">
			<thead>
			<tr>
				<th data-options="field:'sname',width:20">学生名称</th>
				<th data-options="field:'cid_',width:20">班级</th>
				<th data-options="field:'job_status_',width:20,formatter:getshihua">就业状态</th>
				<th data-options="field:'call_status_',width:20">联系状态</th>
			</tr>
			</thead>
		</table>
	</c:if>
	<c:if test="${activeUser.tid == -1 }">
		<table class="easyui-datagrid" style="width:700px;height:250px" id="dg_dishes_info5"
				data-options="fitColumns:true,border:false,fit:true,rownumbers:true,singleSelect:true,url:'<%=request.getContextPath()%>/addController/listStudent',method:'get',pagination:true">
			<thead>
				<tr>
					<th data-options="field:'sname',width:20">学生名称</th>
					<th data-options="field:'cid_',width:20">班级</th>
					<th data-options="field:'job_status_',width:20,formatter:getshihua">就业状态</th>
					<th data-options="field:'call_status_',width:20">联系状态</th>
				</tr>
			</thead>
		</table>
	</c:if>
	<script type="text/javascript">
			var toolbar = [{
				text:'添加学生',
				iconCls:'icon-add',
				handler:function(){
					$('#ff_dishes_info_add6').form("clear");
					$("#dlg_dishes_info_add0").dialog("open");
				}
			
			}];
	</script>
	<div id="dlg_dishes_info_add0" class="easyui-dialog" title="STUDENT" data-options="closed:true,iconCls:'icon-save'" style="width:300px;height:200px;padding:10px">
		<form id="form1" method="post">
	    	<table>
			<tr align="center">
			<td>学生姓名:</td>
			<td><input class="easyui-validatebox" type="text" name="sname" id="sname"></td>
			</tr>
			<tr align="center">
			<td>班级:</td>
			<td>
				<select style="width: 140px;" name="cid" id="ccid">
	    		</select>
			</td>
			</tr>
			<tr align="center">
			<td>就业状态:</td>
			<td>
				<select name="job_status" id="job_status">
					<option value="0">--请选择--</option>
					<option value="1">就业</option>
					<option value="2">未就业</option>
				</select>
			</td>
			</tr>
			<tr align="center">
			<td>联系状态:</td>
			<td>
				<select name="call_status" id="call_status">
					<option value="0">--请选择--</option>
					<option value="1">正常</option>
					<option value="2">失联</option>
				</select>
			</td>
			</tr>
			
		</table>
	    </form>
	    <div style="text-align:center;padding:5px">
	    	<button  class="easyui-linkbutton" onclick="submit1()">提交</button>
	    	<button  class="easyui-linkbutton" onclick="clearForm()">清空</button>
	    </div>
	</div>
	<script type="text/javascript">
	function getshihua(value,row,index){
		//return "<input type='button' value='详情' onclick='openPanel("+row.id+")'/>";
		return row==1?"就业":"未就业";
	}
	$(function(){
		$.ajax({
			type:"post",
			url:"<%=request.getContextPath()%>/addController/listByClasses",
			dataType:"json",
			data:{},
			success:function(classes){
				$("#ccid").empty();
				for(var a in classes){
					$("#ccid").append("<option value='"+classes[a].id+"'>"+classes[a].name+"</option>")
				}
			}
			
		})
	})

	function clearForm(){
		$("#ff_dishes_info_add6").form("clear");
		
	}
	function submit1(){
		$('#form1').form('submit', {
			url:'<%=request.getContextPath()%>/addController/doAddStudent',
			success:function(data){
				if(data){
					$.messager.show({
						title:'温馨提示',
						msg:'恭喜您！添加成功！',
						timeout:3000,
						showType:'slide'
					});
					$('#dlg_dishes_info_add0').dialog('close');
					$("#dg_dishes_info5").datagrid("reload");
				}
				else
				{
					$.messager.alert('信息提示','提交失败！','info');
				}
			}
		});
	}
		<%-- function submit_dishes_info_add(){
			var sname = $("#sname").val();
			var cid = $("#ccid").val();
			var job_status = $("#job_status").val();
			var call_status = $("#call_status").val();
			/* $("#ff_dishes_info_add6").ajaxSubmit({ */
				$.post(
				"<%=request.getContextPath()%>/addController/doAddStudent",
				$("#ff_dishes_info_add6").serialize(),
			    function(flag){
			     	if(flag){
			     		alert(flag);
						$.messager.show({
							title:'温馨提示',
							msg:'恭喜您！添加成功！',
							timeout:3000,
							showType:'slide'
						});
						$("#dlg_dishes_info_add0").dialog("close");
						$("#dg_dishes_info5").datagrid("reload");
					}else{
						$.messager.show({
							title:'温馨提示',
							msg:'对不起！添加失败！',
							timeout:3000,
							showType:'slide'
						});
					  $("#dg_dishes_info5").datagrid("reload");
					},
			     	"json"
				})
			/* });  */
		} --%>
	</script>
	
</body>
</html>